home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 …ember: Reference Library / Dev.CD Dec 94.toast / What's New? / Sample Code / RAMDisk 1.1 / Sources / Driver.a next >
Encoding:
Text File  |  1994-10-13  |  3.6 KB  |  129 lines  |  [TEXT/MPS ]

  1. **
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    Driver.a: MPW DRVR header and glue for RamDisk
  5. **
  6. **    by Gordon Sheridan and Jim Luther
  7. **  modified by Brian Bechtel
  8. **
  9. **    File:        RamCDev.c
  10. **
  11. **    Copyright © 1992-1994 Apple Computer, Inc.
  12. **    All rights reserved.
  13. **
  14. **    You may incorporate this sample code into your applications without
  15. **    restriction, though the sample code has been provided "AS IS" and the
  16. **    responsibility for its operation is 100% yours.  However, what you are
  17. **    not permitted to do is to redistribute the source as "DTS Sample Code"
  18. **    after having made changes. If you're going to re-distribute the source,
  19. **    we require that you make it clear in the source that the code was
  20. **    descended from Apple Sample Code, but that you've made changes.
  21. **
  22. **    Change History (most recent first):
  23. **
  24. **    Change History (most recent first):
  25. **
  26. **         <0>     10/93    gs and JML    Clean up for Sample Code release.
  27. **
  28.  
  29.         STRING    PASCAL
  30.         CASE    ON
  31.  
  32.         MAIN
  33.  
  34.         IMPORT DRVROPEN
  35.         IMPORT DRVRPRIME
  36.         IMPORT DRVRCONTROL
  37.         IMPORT DRVRSTATUS
  38.         IMPORT DRVRCLOSE
  39.  
  40.         INCLUDE 'SysEqu.a'
  41.  
  42.  
  43. DHeader
  44.  
  45. DFlags            DC.B    0                                    ; set by DRVROpen
  46.                 DC.B    0                                    ; set by DRVROpen
  47. DDelay            DC.W    0                                    ; none
  48. DEMask            DC.W    0                                    ; da event mask
  49. DMenu            DC.W    0                                    ; no menu
  50.  
  51.                 DC.W    DOpen     - DHeader                    ; offset to Open
  52.                 DC.W    DPrime     - DHeader                    ; offset to Prime
  53.                 DC.W    DControl - DHeader                    ; offset to Control
  54.                 DC.W    DStatus     - DHeader                    ; offset to Status
  55.                 DC.W    DClose     - DHeader                    ; offset to Close
  56.  
  57. Name            DC.B    '.RamDRVR'                            ; name of driver
  58.                 ALIGN    2                                    ; word align
  59.  
  60. DOpen            pea        DRVROPEN
  61.                 bra.s    DRVRDispatch
  62.                 
  63. DPrime            pea        DRVRPRIME
  64.                 bra.s    DRVRDispatch
  65.                 
  66. DControl        pea        DRVRCONTROL
  67.                 bra.s    DRVRDispatch
  68.  
  69. DStatus            pea        DRVRSTATUS
  70.                 bra.s    DRVRDispatch
  71.  
  72. DClose            pea        DRVRCLOSE                ; and fall thru to DRVRDispatch
  73.  
  74. DRVRDispatch
  75.                 movem.l    a0/a1, -(sp)            ; save registers (for IODone)
  76.                 
  77. ; call driver routines with Pascal calling conventions
  78.                 clr.w    -(sp)                    ; save room for result
  79.                 move.l    a0, -(sp)                ; push paramblock ptr on stack
  80.                 move.l    a1, -(sp)                ; push dce ptr on stack
  81.                 movea.l $12(sp), a0                ; load address of driver routine into a0
  82.                 jsr        (a0)                    ; go to it!
  83.                 
  84.                 move.w    (sp)+, d0                ; put result into d0                
  85.                 movem.l    (sp)+, a0/a1            ; restore registers (for IODone)
  86.                 addq.w    #4, a7                    ; clear driver routine address off stack
  87.  
  88. ; Check for special case exits (Open, Close, KillIO, Immediate, incomplete Async)
  89. ; Open, Close and KillIO always RTS to the Device Manager with the driver result
  90. ; in 
  91.  
  92.                 move.w    ioTrap(a0), d1            ; copy low byte of trap word to d1
  93.  
  94.     ; _Open check
  95.                 tst.b    d1                        ; _Open == A000
  96.                 beq.s    Done                    ; rts if _Open
  97.  
  98.     ; _Close check
  99.                 cmpi.b    #1, d1                    ; _Close == A001
  100.                 beq.s    Done                    ; rts if _Close
  101.  
  102.     ; _KillIO check
  103.                 cmpi.b    #6, d1                    ; _KillIO == A006
  104.                 beq.s    Done                    ; rts if _KillIO
  105.  
  106.     ; It must be _Read, _Write, _Control, or _Status
  107.     
  108.     ; Immediate check
  109.                 btst    #noQueueBit, d1            ; test immediate bit
  110.                 beq.s    NotImmediate            ; branch if not immediate
  111.                 move.w    d0, ioResult(a0)        ; The Device Manager doesn't set ioResult,
  112.                                                 ; so we do just in case the caller checks
  113.                                                 ; ioResult instead of the function result.
  114.                 bra.s    Done                    ; rts if immediate
  115.                 
  116. NotImmediate
  117.  
  118.     ; Incomplete Async check
  119.                 cmp.w    #1, d0                    ; We're using the convention that if the
  120.                                                 ; driver result = 1 then the device driver
  121.                                                 ; hasn't completed the non-immediate
  122.                                                 ; operation.
  123.                 beq.s    Done                    ; rts if the operation is incomplete
  124.  
  125.                 move.l    JIODone, -(sp)            ; push jIODone onto stack
  126. Done            rts
  127.  
  128.                 END
  129.